package cn.longge.mapper;

import cn.longge.entity.SysUser;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface SysUserMapper extends Mapper<SysUser> {
    @Select("select su.id,su.name from sys_user su,sys_user_role sur\n" +
            "where su.del_flag = '0' \n" +
            "and sur.del_flag = '0' \n" +
            "and su.id = sur.user_id \n" +
            "and sur.role_id = #{uid}")
    List<SysUser> selectByRoleId(int id);

    @Select("select su.id,su.name from sys_user su,sys_office so \n" +
            "where su.del_flag = '0'\n" +
            "and so.del_flag = '0'\n" +
            "and so.id = #{oid}\n" +
            "and su.office_id = so.id  \n" +
            "and su.id not in(select sur.user_id from sys_user_role sur where sur.role_id = #{rid})")
    List<SysUser> selectByOfficeId(@Param("oid") Long oid, @Param("rid") Long rid);
}